package com.superarai.util.resource;

import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

import com.superarai.util.text.StringUtil;

public class PropertiesUtil {
	ResourceBundle resourceBundle;
	
	public PropertiesUtil(String path) {
		this.resourceBundle = ResourceBundle.getBundle(path);
	}
	
	public String getValue(String key) {
		return resourceBundle.getString(key);
	}
	/**
	 * 文字列を取得する。
	 * 
	 * @param key
	 * @param inputStringKey
	 * @return
	 */
	public String getValue(String key, String... replaceTextKeys) {
		
		String value = resourceBundle.getString(key);
		List<String> replaceText = new ArrayList<String>();
		
		StringBuilder buff = new StringBuilder();
		for(String in : replaceTextKeys) {
			buff.delete(0, buff.length());
			buff.append(key).append(".").append(in);
			String s = resourceBundle.getString(buff.toString());
			replaceText.add(s);
		}

		return StringUtil.replacePlaceHolder(value, (String[]) replaceText.toArray(new String[0]));
	}
}
